import axios from 'axios'


const API_URL = "http://localhost:8080/app/orders"

export const ordersDetail=(orderId)=>{
    return axios.get(`${API_URL}/orderId/${orderId}`)
}

export const getByPageAndStatus=(userId,pageNumber,OrderStatus)=>{
    return axios.get(`${API_URL}`,{params: {
    userId:userId,
    page: pageNumber,
    status: OrderStatus
  }})
}

export const createOrder=(orderInfo,formToken)=>{
    return axios.post(`${API_URL}/create`,orderInfo,{
    headers: {
      "formToken": formToken
    }
  })
}


// 获取订单取规则信息
export function getOrderCancelRules() {
  return axios.get(`http://localhost:8080/app/order-cancel-rules`)
}

// 已支付订单提前取消
export function cancelPaidOrder(orderId) {
  return axios.post(`${API_URL}/cancelEarly/${orderId}`)
}

